package com.summer.main;

public class FansheTest {
	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		A aa = new A();
		A a = Buile.crate();
		
		B b = Buile.create();
		b.a.todo();
	}

	public static class A {
		public void todo(){
			
		}
	}
	
	public static class AA extends A{
		public void todo(){
			
		}
	}
	
	public static class Buile{
		public static A crate(){
			return new A();
		}
		
		public static B create() throws InstantiationException, IllegalAccessException, ClassNotFoundException{
			//依托于配置
			
			B b = new B();
			String AAclassName = readXML();
			b.setA((A) Class.forName(AAclassName).newInstance());
			return b;
		}
		
		public static String readXML(){
			return "AA";
		}
	}
	
	public static class B{
		public A a;
		void setA(A a){
			this.a = a;
		}
	}
	
}
